package  
{
	import org.flixel.FlxButton;
	import org.flixel.FlxSprite;
	import org.flixel.FlxPoint;
	import org.flixel.FlxState;
	import org.flixel.FlxText;
	import org.flixel.FlxG;
	import org.flixel.FlxU;
	/**
	 * ...
	 * @author João Brant
	 */
	public class MenuState extends FlxState
	{
		[Embed(source = "../assets/telas/back.png")]
		public var background:Class;
		public var backgroundSprite:FlxSprite;
		
		public var beginButton:FlxButton;
		public var clickToBeginText:FlxText;
		public var textoCreditos:FlxText;
		
		public var yPosTexto:int = Main.windowHeight - 130;
		public var floatCreditos:Number = 0;
		
		public function MenuState() 
		{
			super();
			
			backgroundSprite = new FlxSprite(0, 0, background);
			add(backgroundSprite);
		}
		
		public override function create():void
		{
			textoCreditos = new FlxText(15, yPosTexto, 400, "Credits:\nLucas \"Doft\" Mello\nLucas \"Raso\" Mattos\nJoão \"Brantkings\" Brant\nMusic by: ocularnebula.newgrounds.com\/\nFor LudumDare25! Thanks for playin'");
			textoCreditos.setFormat(null, 13, 0xffffff,"center", 0);
			add(textoCreditos);
			
			var someText:FlxText = new FlxText(0, 30, 800, "Just Politics!");
			someText.setFormat(null, 60, 0xffffff,"center", 0);
			add(someText);
			
			clickToBeginText = new FlxText(Main.windowWidth * 0.5 - 130 * 0.5,
								Main.windowHeight * 0.5 - 50, 130, "Click to begin!");
			clickToBeginText.setFormat(null, 14);
			add(clickToBeginText);
			
			beginButton = new FlxButton(Main.windowWidth / 2, clickToBeginText.y, "Start Game!", beginGame);
			beginButton.color = 0xd5ce91;
			beginButton.changeButtonSize(2, 2);
			beginButton.x = Main.windowWidth / 2 - beginButton.width / 2;
			beginButton.y = clickToBeginText.y + beginButton.height*2;
			add(beginButton);
		}
		
		public override function update():void
		{
			super.update();
			
			textoCreditos.y = yPosTexto + Math.sin(floatCreditos * 0.04) * 6;		
			floatCreditos++;
		}
		
		private function beginGame():void
		{
			PlayerData.level = 0;
			PlayerData.dinheiro_atual = 0;
			PlayerData.dinheiro_lastSprint = 0;
			PlayerData.dinheiro_total = 0;
			
			PlayerData.hasImposto1 = false;
			PlayerData.hasImposto2 = false;
			PlayerData.hasImposto3 = false;
			PlayerData.hasPropina1 = false;
			PlayerData.hasPropina2 = false;
			PlayerData.hasPropina3 = false;
			PlayerData.hasCensura1 = false;
			PlayerData.hasCensura2 = false;
			PlayerData.hasCensura3 = false;
			
			PlayerData.hasSaidaPrisao = false;
			PlayerData.equipedSaidaPrisao = false;
			PlayerData.hasAcessorImprensa = false;
			PlayerData.equipedAcessorImprensa = false;
			
			PlayerData.shopUnlocked = false;
			PlayerData.won = false;
		
			FlxG.switchState(new FirstScreen());
		}
		
	}

}